package com.le.tester.javaThink.fifth.chapter12_Collections;

import com.le.tester.javaThink.fourth.typeinfo.pets.Pet;
import com.le.tester.javaThink.fourth.typeinfo.pets.Pets;

import java.util.List;
import java.util.ListIterator;

/**
 * createTime：2021/8/27 15:40
 * description：ListIteration
 */
public class ListIteration {
    public static void main(String[] args) {
        List<Pet> pets = Pets.arrayList(8);
        ListIterator<Pet> it = pets.listIterator();
        while (it.hasNext())
            System.out.print(it.next() +
                    ", " + it.nextIndex() +
                    ", " + it.previousIndex() + ";");
        System.out.println();

        while (it.hasPrevious())
            System.out.print(it.previous().id() + " ");
        System.out.println();
        System.out.println(pets);

        it = pets.listIterator(3);
        while (it.hasNext()) {
            it.next();
//            it.set(Pets.get());
        }
        System.out.println(pets);
    }
}
